<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改密码</title>
    <jsp:include page="/public/inc/head.jsp"/>
</head>
<body>
<div id="header" class="navbar navbar-static-top" role="navigation">
    <jsp:include page="/public/inc/top.jsp"/>
</div>
<div class="container-fluid" style="margin-top:5px;margin-bottom:60px;">
    <div class="row">
        <jsp:include page="/public/inc/menu.jsp"/>
        <div class="col-xs-12 col-sm-10">
            <div class="panel panel-primary">
                <div class="panel-body">
                    <form id="form1" action="/login/saveupdatepwd" method="post" enctype="multipart/form-data">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="control-label col-md-2">原密码</label>
                                <div class="col-md-4">
                                    <input type="password" id="oldpwd" name="oldpwd" class="form-control"
                                           placeholder="请输入原密码"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-2">新密码</label>
                                <div class="col-md-4">
                                    <input type="password" id="pwd" name="pwd" class="form-control"
                                           placeholder="请输入密码"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-2">再输一次</label>
                                <div class="col-md-4">
                                    <input type="password" id="againpwd" name="againpwd" class="form-control"
                                           placeholder="请输入密码"/>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-offset-2 col-md-10">
                                <button type="submit" class="btn btn-primary">
                                    <i class="fa fa-floppy-o"></i> 保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<jsp:include page="/public/inc/bottom.jsp"/>
</body>
</html>
<script type="text/javascript">

    $(document).ready(function () {
        $("#form1").bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                oldpwd: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        },
                        stringLength: {
                            min: 6,
                            max: 18,
                            message: '长度必须在6到18位之间'
                        },
                        remote: {
                            type: 'POST',
                            url: '/login/validpwd',
                            message: '原密码输入错误',
                            delay: 3000
                        }
                    }
                },
                pwd: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        },
                        stringLength: {
                            min: 6,
                            max: 18,
                            message: '长度必须在6到18位之间'
                        },
                        identical: {
                            field: 'againpwd',
                            message: '两次密码输入不一致'
                        },
                        different: {
                            field: 'oldpwd',
                            message: '不能与原密码相同'
                        }
                    }
                },
                againpwd: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        },
                        stringLength: {
                            min: 6,
                            max: 18,
                            message: '长度必须在6到18位之间'
                        },
                        identical: {
                            field: 'pwd',
                            message: '两次密码输入不一致'
                        },
                        different: {
                            field: 'oldpwd',
                            message: '不能与原密码相同'
                        }
                    }
                }
            }
        });
        /*.on('success.form.bv', function(e) {
                    // Prevent form submission
                    e.preventDefault();
                    // Get the form instance
                    var $form = $(e.target);
                    // Get the BootstrapValidator instance
                    var bv = $form.data('bootstrapValidator');
                    // Use Ajax to submit form data
                    $.post($form.attr('action'), $form.serialize(), function(result) {
                        console.log(result);
                    }, 'json');
                });*/
    });
</script>